@use "lib/viewport";

:root {
  --category-header-logo-size: 3rem;
  --category-description-width: 760px;
  --category-header-border: 1px solid var(--content-border-color);
}

#navigation-bar {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  margin-bottom: var(--nav-space);
  margin-right: auto;
}

.navigation-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  margin-bottom: var(--nav-space);
  gap: var(--nav-space) 0; // used if the buttons wrap

  > * {
    white-space: nowrap;

    &:not(:last-child) {
      margin-right: var(--space-2);
    }
  }

  .select-kit-header {
    height: 100%;
  }

  @include viewport.until(sm) {
    .edit-category {
      .d-button-label {
        display: none;
      }

      .d-icon {
        margin: 0;
      }
    }
  }

  .dismiss-container-top:empty {
    display: none;
  }
}

.category-heading {
  max-width: 100%;

  &.--has-logo {
    display: flex;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    border: var(--category-header-border);
    padding: var(--space-4);
    border-radius: var(--d-border-radius);
  }

  &__logo.category-logo.aspect-image {
    height: var(--category-header-logo-size);
    width: var(--category-header-logo-size);
    margin-top: calc(1rem - 1cap);
    flex-shrink: 0;
  }

  &__description {
    margin: 0;
    line-height: var(--line-height-large);
    font-size: var(--font-0);
    color: var(--category-boxes-description-text-color);
    max-width: var(--category-description-width);
  }

  &__content {
    flex-grow: 1;
  }

  &__content .badge-category__wrapper {
    font-size: var(--font-up-3);
  }

  &__content .badge-category__name {
    font-weight: bold;
    color: var(--primary);
  }
}

.category-logo.aspect-image {
  width: auto;
  max-height: 150px;
}

@supports (--custom: property) {
  .category-logo.aspect-image {
    --max-height: 150px;
    max-height: var(--max-height);
    max-width: 100%;
    height: auto;

    img {
      width: calc(var(--max-height) * var(--aspect-ratio));
      max-width: 100%;
      height: inherit;
      max-height: var(--max-height);
    }
  }
}

.topic-list.shared-drafts {
  margin-bottom: var(--space-6);
}

#header-list-area {
  background: var(--d-content-background);
}

// Topic list body
.topic-list-item.visited,
.latest-topic-list-item.visited,
.category-topic-link.visited {
  background-color: var(--topic-list-item-background-color--visited);

  a.title:not(.badge-notification) {
    color: var(--title-color--read);
    font-weight: var(--topic-title-font-weight--visited);
  }
}

.topic-list-item {
  background-color: var(--topic-list-item-background-color);

  .post-excerpt {
    margin-top: var(--space-2);
    margin-bottom: var(--space-2);
    font-size: var(--font-down-2);
    word-break: break-word;
  }
}

.topic-list-main-link {
  font-size: var(--d-topic-list-title-font-size);

  a.title {
    word-break: break-word;
    color: var(--title-color);
    font-weight: var(--topic-title-font-weight);
  }

  .anon & {
    a.title:visited:not(.badge-notification) {
      color: var(--title-color--read);
    }
  }

  a.title.visited:not(.badge-notification) {
    color: var(--title-color--read);
  }
}

.sticky-header .topic-list-header {
  position: sticky;
  top: var(--header-offset, 60px);
  background: var(--d-topic-list-header-background-color);
  z-index: 2;
}

.bulk-select-topics-dropdown {
  .select-kit.single-select.dropdown-select-box .select-kit-row {
    .texts .name {
      font-weight: normal;
    }

    .icons {
      font-size: var(--font-down-2);
      margin-right: var(--space-3);
      position: relative;
      top: 0.15em;
    }
  }
}

.topic-list {
  width: 100%;
  border-collapse: collapse;

  .alert {
    margin-bottom: 0;
    font-size: var(--font-0);
  }

  .spinner {
    margin-top: 40px;
  }

  > .topic-list-body > .topic-list-item {
    &.excerpt-expanded .star {
      vertical-align: top;
      margin-top: 2px;
    }

    &.last-visit {
      border-bottom: none;
    }

    .topic-list-separator {
      text-align: center;
    }
  }

  .topic-list-item-separator {
    border: none;

    .topic-list-data {
      border-top: 1px solid var(--danger-medium);
      line-height: 0em;
      padding: 0;
      text-align: center;
    }

    .topic-list-data span {
      position: relative; // Chrome needs this, otherwise the line is above the text
      background-color: var(--secondary);
      color: var(--danger-medium);
      padding: 0 var(--space-2);
      font-size: var(--font-down-1);
    }
  }

  .topic-list-data {
    line-height: var(--line-height-medium);
    text-align: left;
    vertical-align: middle;
  }

  .btn-flat .d-icon {
    color: currentcolor;
  }

  td {
    color: var(--metadata-color);
    font-size: var(--font-0);
  }

  .main-link {
    @extend .topic-list-main-link;

    .raw-topic-link > * {
      // important to prevent clicks registering on non-link elements and resulting in a full page reload
      pointer-events: none;
    }

    // we have a custom focus indicator via .selected
    // we can remove the native one
    .title:focus {
      outline: none;
    }

    .title:focus-visible {
      outline: none;
    }
  }

  .unread-indicator {
    &.read {
      display: none;
    }

    .d-icon {
      vertical-align: middle;
      font-size: var(--font-down-5);
    }
  }

  .link-bottom-line {
    font-size: var(--font-down-1);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-top: var(--d-topic-list-metadata-top-space);
    gap: 0 var(--space-2);
    line-height: var(--line-height-large);

    a.discourse-tag.box {
      padding-top: 0;
      padding-bottom: 0;
    }

    .discourse-tag.box {
      margin-right: var(--space-1);
    }

    .participant-group-wrapper {
      display: flex;
      flex-wrap: wrap;
      gap: var(--space-2);

      .participant-group {
        padding: 0.1em 0.3em;
        border: 1px solid var(--content-border-color);
        border-radius: 0.25em;
        min-width: 3em;

        @include ellipsis;

        > a {
          display: flex;
          align-items: center;
          height: 1.25em;
          color: var(--primary-high);
          font-size: var(--font-down-1);

          .mobile-view & {
            height: 1.1em;
          }

          .d-icon {
            margin-right: 5px;
            font-size: var(--font-down-1);
          }
        }
      }
    }
  }

  .topic-excerpt {
    display: block;
    font-size: var(--font-down-1);
    margin-top: var(--space-1);
    color: var(--excerpt-color);
    word-wrap: break-word;
    line-height: var(--line-height-large);
    padding-right: var(--space-1);
  }

  .num {
    text-align: center;
    font-size: var(--d-topic-list-data-font-size);

    a {
      color: inherit;
    }

    .badge-posts {
      font-weight: 700;
      color: inherit;
      display: inline-block;
      padding: 15px 5px;
    }
  }

  .num.activity {
    a {
      padding: 15px 5px;

      span.relative-date {
        pointer-events: none;
      }
    }
  }
}

.heatmap-high,
.heatmap-high a,
.heatmap-high .d-icon,
.heatmap-high .d-button-label {
  color: #fe7a15 !important;
}

.heatmap-med,
.heatmap-med a,
.heatmap-med .d-icon,
.heatmap-med .d-button-label {
  color: #cf7721 !important;
}

.heatmap-low,
.heatmap-low a,
.heatmap-low .d-icon,
.heatmap-low .d-button-label {
  color: #9b764f !important;
}

.topic-list .heatmap-high {
  font-weight: bold;
}

.loading .topic-list {
  border: 0;
  box-shadow: none;

  .topic-list-item {
    background-color: transparent;
  }
}

#list-area {
  background: var(--d-content-background);
  margin-bottom: 100px;

  .empty-topic-list {
    padding: 10px;
  }

  .unseen {
    background-color: transparent;
    padding: 0;
    border: 0;
    color: var(--danger-medium);
    font-size: var(--font-0);
    cursor: default;
  }
}

.d-icon-thumbtack.unpinned {
  transform: rotate(180deg);
}

.top-title-buttons {
  display: flex;
  margin: var(--space-2) 0;
  flex-wrap: wrap;
  font-size: var(--font-down-1);
  gap: var(--space-2);
}

div.education {
  color: var(--primary);
  margin-bottom: var(--space-8);

  p {
    max-width: 62em;
  }

  .badge-notification {
    vertical-align: text-bottom;
  }
}

.table-heading {
  border-bottom: 3px solid var(--primary-low);
}

// This is not what we want:
//
//     This is an overly-long topic title that would break just right
//     *
//
// Instead, we want the line to break like this:
//
//     This is an overly-long topic title that would break just
//     right *
.topic-post-badges {
  white-space: nowrap;
  align-self: center;
  line-height: var(--line-height-medium);
}

#topic-list-heading {
  line-height: var(--line-height-medium);
  margin-bottom: var(--space-2);
}
